<?php
 /*
 * 1626cms 管理中心 個人用戶相關函數
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
 if(!defined('IN_QISHI'))
 {
 	die('Access Denied!');
 }
 //******************************簡歷部分**********************************
//獲取簡歷信息列表
function get_resume_list($offset,$perpage,$get_sql= '')
{
global $db,$timestamp;
$row_arr = array();
if(isset($offset)&&!empty($perpage))
{
$limit=" LIMIT ".$offset.','.$perpage;
}
$result = $db->query("SELECT * FROM ".table('resume')." ".$get_sql." ORDER BY id DESC ".$limit);
while($row = $db->fetch_array($result))
{
$row['sex']=="1"?$row['sex']="男":$row['sex']="女";
$row['display']=="1"?$row['display']="公開":$row['display']="半公開";
$row['education']=get_jobs_education_one($row['education']);
$row['resume_url']=url_rewrite('resume-show',array('id0'=>$row['id']));
$row_arr[] = $row;
}
return $row_arr;
}
//刪除簡歷(uid)
function del_resume($del_id)
{
global $db;
if (is_array($del_id))
{
$sqlin=implode(",",$del_id);
if (!is_numeric(str_replace(",","",$sqlin))) return false;
if (!$db->query("Delete from ".table('resume')." WHERE uid IN (".$sqlin.")")) return false;
if (!$db->query("Delete from ".table('resume_click')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_education')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_intention')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_intention_area')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_intention_jobs')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_intention_nature')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_intention_trade')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_photo')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_specialty')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_training')." WHERE uid IN (".$sqlin.") ")) return false;
if (!$db->query("Delete from ".table('resume_work')." WHERE uid IN (".$sqlin.") ")) return false;
return true;
}
if (intval($del_id)==$del_id && !is_array($del_id))
{
if (!$db->query("Delete from ".table('resume')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_click')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_education')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_intention')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_intention_area')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_intention_jobs')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_intention_nature')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_intention_trade')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_photo')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_specialty')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_training')." WHERE uid='".$del_id."'")) return false;
if (!$db->query("Delete from ".table('resume_work')." WHERE uid='".$del_id."'")) return false;
return true;
}
return false;
}
//修改簡歷審核狀態
function edit_resume_audit($id,$audit)
{
global $db,$_CFG;
if (!is_numeric($audit)|| $audit+0==0) return false;
if (is_array($id))
{
$sqlin=implode(",",$id);
if (!is_numeric(str_replace(",","",$sqlin))) return false;
if (!$db->query("update  ".table('resume')." SET audit='".$audit."'  WHERE uid IN (".$sqlin.")")) return false;
//發送郵件
	$mailconfig=get_cache('mailconfig');//獲取郵件規則
	if ($audit=="1" && $mailconfig['set_resumeallow']=="1")//審核通過
	{
		$result = $db->query("SELECT * FROM ".table('resume')." WHERE uid IN (".$sqlin.") ");
			while($list = $db->fetch_array($result))
			{
			require_once('../PHPMailer/class.phpmailer.php');
			asyn_sendmail($_CFG['site_domain'].$_CFG['site_dir']."asyn_mail.php?uid=".$list['uid']."&key=".asyn_userkey($list['uid'])."&act=set_resumeallow");
			}
	}
	if ($audit=="3" && $mailconfig['set_resumenotallow']=="1")//審核未通過
	{
		$result = $db->query("SELECT * FROM ".table('resume')." WHERE uid IN (".$sqlin.") ");
			while($list = $db->fetch_array($result))
			{
			require_once('../PHPMailer/class.phpmailer.php');
			asyn_sendmail($_CFG['site_domain'].$_CFG['site_dir']."asyn_mail.php?uid=".$list['uid']."&key=".asyn_userkey($list['uid'])."&act=set_resumenotallow");
			}
	}
//發送郵件
return true;
}
return false;
}
//修改照片審核狀態
function edit_resume_photoaudit($id,$audit)
{
global $db;
if (!is_numeric($audit)|| $audit+0==0) return false;
if (is_array($id))
{
$sqlin=implode(",",$id);
if (!is_numeric(str_replace(",","",$sqlin))) return false;
if (!$db->query("update  ".table('resume')." SET photo_audit='".$audit."'  WHERE uid IN (".$sqlin.") AND photoresume=2 ")) return false;
return true;
}
return false;
}
//修改人才等級
function edit_resume_talent($id,$talent)
{
global $db;
if (!is_numeric($talent)|| $talent+0==0) return false;
if (is_array($id))
{
$sqlin=implode(",",$id);
if (!is_numeric(str_replace(",","",$sqlin))) return false;
if (!$db->query("update  ".table('resume')." SET talent='".$talent."'  WHERE uid IN (".$sqlin.")")) return false;
return true;
}
return false;
}
//從UID獲取簡歷的基本信息
function get_resume_basic($uid){
global $db;
if (intval($uid)!=$uid) return false;
$sql = "select * from ".table('resume')." where uid=".$uid;
$lsit=$db->getone($sql);
return $lsit;
}
//**************************個人會員列表
function get_member_list($offset,$perpage,$get_sql= '')
{
global $db;
$row_arr = array();
if(isset($offset)&&!empty($perpage))
{
$limit=" LIMIT ".$offset.','.$perpage;
}
$result = $db->query("SELECT * FROM ".table('members')." ".$get_sql.$limit);
while($row = $db->fetch_array($result))
{
$resume_basic=get_resume_basic($row['uid']);
$row['resume_name']=$resume_basic['fullname'];
$row['resume_url']=url_rewrite('resume-show',array('id0'=>$resume_basic['id']));
$row_arr[] = $row;
}
return $row_arr;
}
//刪除企業會員
function delete_member($uid)
{
global $db;
if (!is_array($uid)) return false;
$sqlin=implode(",",$uid);
if (!is_numeric(str_replace(",","",$sqlin))) return false;
if (!$db->query("Delete from ".table('members')." WHERE uid IN (".$sqlin.")")) return false;
if (!$db->query("Delete from ".table('members_type')." WHERE uid IN (".$sqlin.")")) return false;
return true;
}
//獲取個人會員單個
function get_member_one($memberuid)
{
global $db;
if (intval($memberuid)!= $memberuid) return false;
$sql = "select * from ".table('members')." where uid=".$memberuid;
$val=$db->getone($sql);
$resume_basic=get_resume_basic($memberuid);
$val['resume_name']=$resume_basic['fullname'];
$val['resume_url']=url_rewrite('resume-show',array('id0'=>$resume_basic['id']));
return $val;
}
//生成會員秘匙，防止異步數據外部提交
function asyn_userkey($uid)
{
$user=get_user(intval($uid));
$key=md5($user['username'].$user['pwd_hash'].$user['password']);
return $key;
}
//獲取會員信息，返回用戶名等相關信息
function get_user($uid){
global $db;
$sql = "select * from ".table('members')." where uid = '$uid'";
$user_info=$db->getone($sql);
return $user_info;
}
?>
